<?php

/**
 * 首页焦点图、达人推荐 -- 删除功能提交程序
 * 
 * @copyright zhanghuan
 * @since 2012-03-23
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/index/db_food_focus_pic_index.class.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/index/db_food_user_daren_index.class.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();

function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	if (!security_check::check_refer())
	{
		throw new Exception("错误的来路", 1);
	}
	
	//id
	cgi::both($g_cgival["uid"], "uid", "");
	if (!cgi_chk::uid($g_cgival["uid"]))
	{
		throw new Exception("参数uid错误");
	}
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	
	$uid = $g_cgival["uid"];
	$admin_log = new admin_log();
	$site_id = admin::admin_get_user_site_id();	// 拿到当前站点的site_id
	$admin_id = admin::admin_get_login_uid();	// 拿到当前管理员ID
	$admin_name = admin::admin_get_login_user_name(); // 拿到当前管理员名称
	
	$db = new db_food_user_daren_index();

	// 执行删除操作
	$res = $db->admin_delete_item_by_uid($site_id, $uid);
	if (!$res) throw new Exception("删除失败");
	$admin_log->admin_insert_log_info($admin_id, $site_id, 12, "删除 首页达人uid={$uid}");
}

try
{
	admin_check_login();
	
	check_cgi_pro();
	get_data();
	
	$g_show["error"] = 0;
	$g_show["errmsg"] = "成功";
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}
show_pro();
exit;

function show_pro()
{
	global $g_show;
	
	echo json_encode($g_show);
}
?>